<template>
  <div class="app-container">
    <!-- <div class="wrap">
      <h2 class="box">年度工作量汇总</h2>
    </div> -->
    <el-row :gutter="12" style="margin-bottom: 20px;">
      <el-card :body-style="{ padding: '0px' }">
        <el-form
          ref="wellDrillingForm"
          :inline="true"
          :model="wellDrillingParams"
          class="demo-form-inline"
          style="margin-left: 20px;"
        >
          <!-- <el-divider content-position="left">基础参数设置</el-divider>
          <el-form-item label="井名">
            <el-input v-model="wellDrillingParams.wellName" placeholder="井名"></el-input>
          </el-form-item>
          <el-form-item label="划分依据">
            <el-select v-model="wellDrillingParams.method" placeholder="划分依据">
              <el-option
                v-for="item in drawMethods"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item> -->
          <!-- <el-divider content-position="left">完井数与完成进尺统计</el-divider> -->
          <el-form-item label="开钻日期">
            <el-date-picker v-model="inverstParams.kzrq" size="small" style="width: 240px"
              value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期"
              end-placeholder="结束日期" />
          </el-form-item>
          <el-form-item label="完钻日期">
            <el-date-picker v-model="inverstParams.wzrq" size="small" style="width: 240px"
              value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期"
              end-placeholder="结束日期" />
          </el-form-item>
          <el-form-item label="完井日期">
            <el-date-picker v-model="inverstParams.wjrq" size="small" style="width: 240px"
              value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期"
              end-placeholder="结束日期" />
          </el-form-item>
          <!-- <el-form-item label="探井投资">
            <el-cascader
              v-model="investParams.explorationInvest"
              :options="investColLists"
              :props="{ value: 'id', label: 'name' }"
              filterable
              placeholder="探井投资"
              style="width: 100%;"
            >
              <template slot-scope="{ node, data }">
                <span>{{ data.name }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader>
          </el-form-item>
          <el-form-item label="钻井投资">
            <el-cascader
              v-model="investParams.drillingInvest"
              :options="investColLists"
              :props="{ value: 'id', label: 'name' }"
              filterable
              placeholder="钻井投资"
              style="width: 100%;"
            >
              <template slot-scope="{ node, data }">
                <span>{{ data.name }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader>
          </el-form-item>
          <el-form-item label="试油投资">
            <el-cascader
              v-model="investParams.oilTestingInvest"
              :options="investColLists"
              :props="{ value: 'id', label: 'name' }"
              filterable
              placeholder="试油投资"
              style="width: 100%;"
            >
              <template slot-scope="{ node, data }">
                <span>{{ data.name }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader>
          </el-form-item>
          <el-form-item label="其他（科研、管理、利息等）">
            <el-cascader
              v-model="investParams.otherInvest"
              :options="investColLists"
              :props="{ value: 'id', label: 'name' }"
              filterable
              placeholder="其他（科研、管理、利息等）"
              style="width: 100%;"
            >
              <template slot-scope="{ node, data }">
                <span>{{ data.name }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader>
          </el-form-item> -->
          <el-form-item>
            <el-button type="primary" :loading="wellDrillingLoading" @click="handleDrawWellDrilling">绘图</el-button>
            <el-button type="success" @click="handleRestWellDrilling">重置</el-button>
          </el-form-item>
        </el-form>
        <div id="investSummary_workload_chart" class="draw_div"></div>
      </el-card>
    </el-row>
    
  </div>
</template>

<script>
import echarts from "echarts";
import { foldLineHistogram, Histogram } from "@/utils/echartsDraw";
import { listAllType } from "@/api/vadmin/budget/channel/channelapi";
import { listType } from "@/api/vadmin/budget/formwork/dataapi";
import { Decrypt } from "@/utils/AesHmacMD5";
import { draw_wellDrilling } from "@/api/vadmin/budget/ledger/ledgerapi";
import { modelToDict } from "@/api/vadmin/budget/formwork/formworkapi";

export default {
  data() {
    return {
      currentDate: new Date(),
      inverstParams: {
        type: "3",
        wellName: '',
        kzrq:[],wzrq:[],wjrq:[]
      },
      
    };
  },
  mounted() {
    this.handleDrawWellDrilling();
  },
  methods: {
    /**
     * 点击钻井工作量进行绘制
     */
    handleDrawWellDrilling() {
      draw_wellDrilling(this.inverstParams).then(response => {
        var titleList = ["试油投资", "钻井投资", "研究费及管理费投资"];
        var resData = JSON.parse(Decrypt(response.data));

        var element = document.getElementById("investSummary_workload_chart");
        var myChart = echarts.init(element);

        Histogram(myChart, titleList, resData.x_weeks, resData.y_weeks);
      }).catch(error => {
      });
    },
    /**
     * 重置-探井工作量
     */
    handleRestWellDrilling() {
      this.wellDrillingParams = {
        type: "1",
        wellName: undefined,
        fileID: undefined,
        method: "1",
        startTime: undefined,
        endTime: undefined,
        completeTime: undefined,
        sum: undefined,
        footage: undefined
      };
      this.wellDrillingBolWellOrFile = true;
      this.resetForm("wellDrillingForm");
      this.oilTesting_workload();
    },
  }
};
</script>

<style>
.time {
    font-size: 13px;
    color: #999;
}

.bottom {
    margin-top: 13px;
    line-height: 12px;
}

.button {
    padding: 0;
    float: right;
}

.image {
    width: 100%;
    display: block;
}

.clearfix:before,
.clearfix:after {
    display: table;
    content: "";
}

.clearfix:after {
    clear: both;
}

.wrap {
    text-align: center;
    /* background-color: #6c6b6b; */
    height: 50px;
    margin-bottom: 10px;
    background-color: #FF3CAC;
    background-image: linear-gradient(225deg, #FF3CAC 0%, #784BA0 50%, #2B86C5 100%);
}

.box {
    color: aliceblue;
    line-height: 50px;
}

.drawDiv {
    float: right;
    line-height: 60px;
}

.draw_div {
    height: 500px;
    width: 100%;
    margin-top: 20px;
}
</style>
